<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>${message("admin.product.list")} - 766 SMART HOME</title>
<meta name="author" content="BIZ Team" />
<meta name="copyright" content="BIZ" />
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/list.js"></script>
<script type="text/javascript" src="${base}/resources/public/js/publicDictionary.js"></script>
<style type="text/css">
.moreTable th {
	width: 80px;
	line-height: 25px;
	padding: 5px 10px 5px 0px;
	text-align: right;
	font-weight: normal;
	color: #333333;
	background-color: #f8fbff;
}

.moreTable td {
	line-height: 25px;
	padding: 5px;
	color: #666666;
}

.promotion {
	color: #cccccc;
}
*{padding: 0px;margin: 0px;}
		button,select{outline: none;}
		ul li{list-style: none;}
		.g-popup{background-color: rgba(51,51,51,0.5);position: fixed;width: 100%;height: 100%;color: #666;display:none;}			
		.g-popup .message{width: 500px;height:250px;margin: 0 auto;background-color: #fff;margin-top: 13%;
			box-shadow: 0px 0px 3px;border: 1px solid #E7F5FF;}
		.g-popup .message h5{position: relative;padding: 10px;background-color: #E7F5FF;color: #666666;
			border-bottom: 1px solid #CADCEA;}
		.message h5 span{display: inline-block;width: 24px;height: 17px;position: absolute;top: -1px;right: 10px;
				cursor: pointer;background: url(${base}/resources/admin/images/btn.png) -0px -10px no-repeat;}
		.message h5 span:hover{background: url(${base}/resources/admin/images/btn.png) -27px -10px no-repeat;}
		.message div li{display: inline-block;width: 30%;text-align: center;}
		.message div{font-size: 15px;padding: 10px;height: 150px;	}
		.message>div{border-bottom: 1px solid #CADCEA;}
		.message div li select{width: 100px;margin: 0px 10px;}
		.message div ul{margin-top: 30px;}
		.message .popup-btn{height: 30px;border: none;text-align: right;}
		.message .popup-btn button{margin: 0px 5px;padding: 2px 5px;cursor: pointer;border-radius: 3px;}
		.btn-submit{background-color:#D1E8F4;border: 1px solid #D1E8F4;			}
		.btn-cancel{background-color:#E95907;border: 1px solid #E95907;color: #fff;
}
.g-popup{
	top:0px;
}
</style>
<script type="text/javascript">
$().ready(function() {
	var $listForm = $("#listForm");
	var $moreButton = $("#moreButton");
	var $filterOption = $("#filterOption a");
	
	[@flash_message /]
	
	// 筛选选项
	$filterOption.click(function() {
		var $this = $(this);
		var $dest = $("#" + $this.attr("name"));
		if ($this.hasClass("checked")) {
			$dest.val("");
		} else {
			$dest.val($this.attr("val"));
		}
		$listForm.submit();
		return false;
	});
	$("#deleteButton").click( function() {
		var ids=getIds();
		if(!ids){
			$.message("error","请选择一条数据！");
			return false;
		}
		$.dialog({
			type: "warn",
			content: message("admin.dialog.deleteConfirm"),
			ok: message("admin.dialog.ok"),
			cancel: message("admin.dialog.cancel"),
			onOk: function() {
				window.location.href="delete.jhtml?id="+ids;
			}
		});
	});
	//排序
	$(".sort").click(function(){
		var properties = $(this).attr("info")+" "+$(this).attr("sort");
		var sorts = $(this).attr("sort");
		if(sorts =='' || sorts=='asc' ){
			if(sorts==''){
				properties=properties+" asc";
			}
			sorts = "desc";
			$(this).attr("sort"," desc");
		}else{
			sorts = "asc";
			$(this).attr("sort"," asc");
		}
		sort(properties,sorts);
	});
});
function  getIds (){
	var arrChk=$("input[name='ids']:checked");
	if(arrChk.length>0){
		var str="";
		for(var i=0;i<arrChk.length;i++){
			var id=arrChk[i].value;
			if(i<arrChk.length-1){
				str+=id+",";
			}else{
				str+=id;
			}
		}
		return str.split(",");
	}
	return null;
}
function sort(properties,sorts){
		window.location.href="list.jhtml?properties="+properties+"&sort="+sorts;
}

</script>
</head>
<body>
	<div class="path">
		<a href="${base}/admin/common/index.jhtml">${message("admin.path.index")}</a> &raquo;门店列表<span>(${message("admin.page.total", page.total)})</span>
	</div>
	<form id="listForm" action="list.jhtml" method="get">
		<input type="hidden" id="productCategoryId" name="productCategoryId" value="${productCategoryId}" />
		<input type="hidden" id="brandId" name="brandId" value="${brandId}" />
		<input type="hidden" id="promotionId" name="promotionId" value="${promotionId}" />
		<input type="hidden" id="tagId" name="tagId" value="${tagId}" />
		<input type="hidden" id="isMarketable" name="isMarketable" value="[#if isMarketable??]${isMarketable?string("true", "false")}[/#if]" />
		<input type="hidden" id="isList" name="isList" value="[#if isList??]${isList?string("true", "false")}[/#if]" />
		<input type="hidden" id="isTop" name="isTop" value="[#if isTop??]${isTop?string("true", "false")}[/#if]" />
		<input type="hidden" id="isGift" name="isGift" value="[#if isGift??]${isGift?string("true", "false")}[/#if]" />
		<input type="hidden" id="isOutOfStock" name="isOutOfStock" value="[#if isOutOfStock??]${isOutOfStock?string("true", "false")}[/#if]" />
		<input type="hidden" id="isStockAlert" name="isStockAlert" value="[#if isStockAlert??]${isStockAlert?string("true", "false")}[/#if]" />
		<div class="bar">
			<div class="buttonWrap">
				<a href="javascript:;" id="deleteButton" class="iconButton disabled">
					<span class="deleteIcon">&nbsp;</span>${message("admin.common.delete")}
				</a>
				<a href="javascript:;" id="refreshButton" class="iconButton">
					<span class="refreshIcon">&nbsp;</span>${message("admin.common.refresh")}
				</a>
				<div class="menuWrap">
					<div class="popupMenu">
						<ul id="filterOption" class="check">
							<li>
								<a href="javascript:;" name="isMarketable" val="true"[#if isMarketable?? && isMarketable] class="checked"[/#if]>${message("admin.product.isMarketable")}</a>
							</li>
							<li>
								<a href="javascript:;" name="isMarketable" val="false"[#if isMarketable?? && !isMarketable] class="checked"[/#if]>${message("admin.product.notMarketable")}</a>
							</li>
							<li class="separator">
								<a href="javascript:;" name="isList" val="true"[#if isList?? && isList] class="checked"[/#if]>${message("admin.product.isList")}</a>
							</li>
							<li>
								<a href="javascript:;" name="isList" val="false"[#if isList?? && !isList] class="checked"[/#if]>${message("admin.product.notList")}</a>
							</li>
							<li class="separator">
								<a href="javascript:;" name="isTop" val="true"[#if isTop?? && isTop] class="checked"[/#if]>${message("admin.product.isTop")}</a>
							</li>
							<li>
								<a href="javascript:;" name="isTop" val="false"[#if isTop?? && !isTop] class="checked"[/#if]>${message("admin.product.notTop")}</a>
							</li>
							<li class="separator">
								<a href="javascript:;" name="isGift" val="true"[#if isGift?? && isGift] class="checked"[/#if]>${message("admin.product.isGift")}</a>
							</li>
							<li>
								<a href="javascript:;" name="isGift" val="false"[#if isGift?? && !isGift] class="checked"[/#if]>${message("admin.product.nonGift")}</a>
							</li>
							<li class="separator">
								<a href="javascript:;" name="isOutOfStock" val="false"[#if isOutOfStock?? && !isOutOfStock] class="checked"[/#if]>${message("admin.product.isStack")}</a>
							</li>
							<li>
								<a href="javascript:;" name="isOutOfStock" val="true"[#if isOutOfStock?? && isOutOfStock] class="checked"[/#if]>${message("admin.product.isOutOfStack")}</a>
							</li>
							<li class="separator">
								<a href="javascript:;" name="isStockAlert" val="false"[#if isStockAlert?? && !isStockAlert] class="checked"[/#if]>${message("admin.product.normalStore")}</a>
							</li>
							<li>
								<a href="javascript:;" name="isStockAlert" val="true"[#if isStockAlert?? && isStockAlert] class="checked"[/#if]>${message("admin.product.isStockAlert")}</a>
							</li>
						</ul>
					</div>
				</div>
				<div class="menuWrap">
					<a href="javascript:;" id="pageSizeSelect" class="button">
						${message("admin.page.pageSize")}<span class="arrow">&nbsp;</span>
					</a>
					<div class="popupMenu">
						<ul id="pageSizeOption">
							<li>
								<a href="javascript:;"[#if page.pageSize == 10] class="current"[/#if] val="10">10</a>
							</li>
							<li>
								<a href="javascript:;"[#if page.pageSize == 20] class="current"[/#if] val="20">20</a>
							</li>
							<li>
								<a href="javascript:;"[#if page.pageSize == 50] class="current"[/#if] val="50">50</a>
							</li>
							<li>
								<a href="javascript:;"[#if page.pageSize == 100] class="current"[/#if] val="100">100</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<table id="listTable" class="list">
			<tr>
				<th class="check">
					<input type="checkbox" id="selectAll" />
				</th>
				<th>
					<a href="javascript:;" class="sort" info="id" sort="${sort}" id="id" name="id">预约编号</a>
				</th>
				<th>
					<a href="javascript:;" class="sort" info="aname" sort="${sort}" name="aname">预约人姓名</a>
				</th>
				<th>
					<a href="javascript:;" class="sort" info="phone" sort="${sort}" name="phone">预约人电话</a>
				</th>
				<th>
					<a href="javascript:;" class="sort" info="measure" sort="${sort}" name="measure">面积</a>
				</th>
				<th>
					<a href="javascript:;" class="sort" info="appointment" sort="${sort}" name="appointment">预约时间</a>
				</th>
				<th>
					<a href="javascript:;" class="sort" info="handle" sort="${sort}" name="handle">状态</a>
				</th>
				<th>
					<a href="javascript:;" class="sort" info="handle" sort="${sort}" name="handle">跟单人</a>
				</th>
				<th>
					<a href="javascript:;">操作</a>
				</th>
				<th>
					<a href="javascript:;" class="sort" info="shops_id" sort="${sort}" name="shops_id">服务门店</a>
				</th>
				<th>
					<a href="javascript:;">操作</a>
				</th>
			</tr>
			[#list page.content as li]
				<tr>
					<td>
						<input type="checkbox" name="ids" value="${li.id}" />
					</td>
					<td>
						${li.id}
					</td>
					<td>
						${li.aName}
					</td>
					<td>
						${li.phone}
					</td>
					<td>
						${li.measure}
					</td>
					<td>
						${li.appointment?string("yyyy-MM-dd HH:mm:ss")}
					</td>
					[#if li.handle==1]
					<td>
						已处理
					</td>
					[#else]
					<td>
						未处理
					</td>
					[/#if]
					<td>
						<select class="option" name="withSingle" [#if li.withSingle!=null]disabled="disabled" style="background:transparent;box-shadow:none;border:none;appearance:none;-moz-appearance:none;-webkit-appearance:none;"[/#if]>
					 		<option value="">--请选择--</option>
					 		[#list dc as dc]
					 			<option value="${dc.id}" info="${dc.id},${li.withSingle}" [#if dc.id==li.withSingle]selected="selected"[/#if]>${dc.title}</option>
					 		[/#list]
					 	</select>
					</td>
					[#if li.handle==0]
					<td>
						<a href="javascript:;" class="handle">指定跟单人</a>
					</td>
					[#else]
					<td></td>
					[/#if]
					<td>
						${li.shopsName}
					</td>
					<td><a href="javascript:;" class="handleTwo">[#if li.shopsId==null]指定门店[#else][/#if]</a></td>
				</tr>
			[/#list]
		</table>
		[@pagination pageNumber = page.pageNumber totalPages = page.totalPages]
			[#include "/admin/include/pagination.ftl"]
		[/@pagination]
	</form>
	<div class="g-popup">
		<div class="message">
			<h5>选择门店
			<span class="cancel"></span></h5>
			<div class="">
				<ul>
					<li>省<select name="provinceId">
							<option value="">---请选择---</option>
							[#list parentList as li]
								<option value="${li.id}">${li.name}</option>
						 	[/#list]
					</select>
					</li>
					<li>市<select id="selectCity" name="cityId">
							<option value="">---请选择---</option>
					</select>
					</li>
					<li class="parent">区<select name="areaId">
							<option value="">---请选择---</option>
					</select>
					</li>
				</ul>
				<div class="">
					服务门店: <select name="shopsId">
						<option value="">-----请选择-----</option>
					</select>
				</div>
			</div>
			<div class="popup-btn">
				<button class="btn-submit">确 定</button><button class="btn-cancel">取 消</button>
			</div>
		</div>
	</div>
</body>
<script>
	$(".handle").click(function(){
		var id = $(this).parent().parent().find("[name=ids]").val();
		var withSingle = $(this).parent().parent().find("[name=withSingle]").val();
		if(withSingle.length<1){
			$.message("error","请选择跟单人");
			return;
		}else{
			window.location.href="${base}/admin/appointment/update.jhtml?id="+id+"&withSingle="+withSingle;
		}
	});
	$(".handleTwo").click(function(){
		var id = $(this).parent().parent().find("[name=ids]").val();
		var withSingle = $(this).parent().parent().find("[name=withSingle]").val();
		if(withSingle.length<1){
			$.message("error","没有跟单人,暂时不能处理");
			return;
		}
		$(".g-popup").fadeIn();
		$(".g-popup .btn-submit").attr("infoOne",id);
		$(".g-popup .btn-submit").attr("infoTwo",withSingle);
	});
	$("[name=provinceId]").change(function(){
		var provinceId = $(this).val();
		$.ajax({
		    url:"${base}/admin/appointment/getChildrenByParentId.jhtml",    //请求的url地址
		    dataType:"json",   //返回格式为json
		    data:{"provinceId":provinceId},    //参数值
		    type:"GET",   //请求方式
		    success:function(req){
		        //请求成功时处理
		        $("[name=cityId]").empty();
		        $("[name=cityId]").append("<option value=''>--请选择--</option>");
		        for(var i=0;i<req.length;i++){
		        	$("[name=cityId]").append("<option value='"+req[i].id+"'"+"info='"+req[i].fullName+"'>"+req[i].name+"</option>");
		        }
		    },
		    error:function(){
		        //请求出错处理
		    }
		});
	});
	$("[name=cityId]").change(function(){
		var provinceId = $(this).val();
		$.ajax({
		    url:"${base}/admin/appointment/getChildrenByParentId.jhtml",    //请求的url地址
		    dataType:"json",   //返回格式为json
		    data:{"provinceId":provinceId},    //参数值
		    type:"GET",   //请求方式
		    success:function(req){
		        //请求成功时处理
		        $("[name=areaId]").empty();
		        $("[name=areaId]").append("<option value=''>--请选择--</option>");
		        for(var i=0;i<req.length;i++){
		        	$("[name=areaId]").append("<option value='"+req[i].id+"'"+"info='"+req[i].fullName+"'>"+req[i].name+"</option>");
		        }
		        if(req.length<1){
		        	getShops(provinceId);
		        }
		    },
		    error:function(){
		        //请求出错处理
		    }
		});
	});
	$("[name=areaId]").change(function(){
		var areaId = $(this).val();
		getShops(areaId);
	});
//关闭
$('btn-submit,.btn-cancel,cancel').on('click',function(){
			$('.g-popup').fadeOut();
});
function getShops(areaId){
	$.ajax({
	    url:"${base}/admin/appointment/getShopsByAreaId.jhtml",    //请求的url地址
	    dataType:"json",   //返回格式为json
	    data:{"areaId":areaId},    //参数值
	    type:"GET",   //请求方式
	    success:function(req){
	        //请求成功时处理
	        $("[name=shopsId]").empty();
	        $("[name=shopsId]").append("<option value=''>--请选择--</option>");
	        for(var i=0;i<req.length;i++){
	        	$("[name=shopsId]").append("<option value='"+req[i].id+"'"+"info='"+req[i].shopsName+"'>"+req[i].shopsName+"</option>");
	        }
	    },
	    error:function(){
	        //请求出错处理
	    }
	});
};
$(".btn-submit").click(function(){
	var shopsId = $("[name=shopsId]").val();
	var id = $(this).attr("infoOne");
	var withSingle = $(this).attr("infoTwo");
	window.location.href="${base}/admin/appointment/update.jhtml?id="+id+"&withSingle="+withSingle+"&shopsId="+shopsId;
});
</script>
</html>